<html>
<!-- link: http://barretlee.github.io/myPromise/test/p-m.html !-->
<script src="promise-minus.js"></script>
<script>
var promise = new Promise(function(data){
	console.log(data);
	return 1;
});
promise.then(function(data){
	return (function(data){
		var promise = new Promise();

		setTimeout(function(){
			console.log(data);

			promise.resolve(2);
		}, 1000);

		return promise;
	})(data);

}).then(function(data){
	return (function(data){
		var promise = new Promise();

		setTimeout(function(){
			console.log(data);

			promise.resolve(3);
		}, 1000);

		return promise;
	})(data);
}).then(function(data){
    return (function(data){
		var promise = new Promise();

		setTimeout(function(){
			console.log(data);
    		console.log("end");

			promise.resolve(3);
		}, 1000);

		return promise;
	})(data);
});
debugger;
promise.resolve("start");
</script>